<template>
  <div>
    <el-dialog v-model="drawerStore.tagDialog" title="新增标签" width="500" align-center>
     <el-form :model="form">
       <el-form-item label="标签名">
         <el-input v-model="form.name" autocomplete="off" />
       </el-form-item>
       <el-form-item label="状态">
         <el-select v-model="form.status" placeholder="请选择状态">
           <el-option label="启用" value="1" />
           <el-option label="禁用" value="0" />
         </el-select>
       </el-form-item>
     </el-form>
     <template #footer>
       <div class="dialog-footer">
         <el-button @click="drawerStore.tagDialog = false">取消</el-button>
         <el-button type="primary" @click="confirm">确认</el-button>
       </div>
     </template>
    </el-dialog>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { useDrawerStore } from '@/stores/drawer';
import { addTag } from '@/apis/admin/tags';
import { ElMessage } from 'element-plus'

const drawerStore = useDrawerStore();
const form = ref({
  name: '',
  status: '1'
});

async function confirm(){
  await addTag(form.value);
  ElMessage({
    message: '新增成功',
    type: 'success',
  });
  drawerStore.tagDialog = false;
}
</script>

<style scoped>

</style>
